'use strict';
const BaseController = require('../base');
const { NotFound } = require('@utils/http-exception');

class CommonsController extends BaseController {
  async citys() {
    const { app } = this;
    try {
      const result = await app.httpclient.request(
        'https://apis.imooc.com/?icode=8C1A3A54BB659B78',
        {
          dataType: 'json',
        }
      );
      if (result.status === 200) {
        this.success(result.data.citys);
      } else {
        throw new NotFound();
      }
    } catch (error) {
      throw new NotFound();
    }
  }
}

module.exports = CommonsController;
